import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);
const store = new Vuex.Store({
    state: {
        //用户信息
        member: null,
        // 加载状态
        mainLoading: false,
        lawData :{},
        loginState:false,
        regState:false,
    },
    mutations: {
        //更新用户信息
        login(state, payload) {
            state.member = payload;
        },
        // loading的显示
        mainLoading(state, show) {
            state.mainLoading = show;
        },
        SET_LAW:(state,list)=>{
            state.lawData = list;
        },
        SET_LOGIN_STATE:(state,status)=>{
            state.loginState = status;
        },
        SET_REG_STATE:(state,status)=>{
            state.regState = status;
        }
    },
    actions: {
        login({ commit, state }, payload) {
            commit('login', payload);
        },
        setLawList({ commit, state },data){
            commit('SET_LAW',data)
        },
        login:({commit},status)=>{
            commit('SET_LOGIN_STATE',status);
        },
        changeRegState:({commit},status)=>{
            commit('SET_REG_STATE',status);
        },
    },
});

export default store;
